home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / GLE / HELIX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  1.1 KB  |  49 lines

  1.  
  2. /* 
  3.  * helicoid (gernalized torus) demo 
  4.  *
  5.  * FUNCTION:
  6.  * This code provides a very simple example of the helicoid primitive.
  7.  * Most of this code is required to set up OpenGL and GLUT, and very
  8.  * very little to set up the helix drawer. Don't blink!
  9.  *
  10.  * HISTORY:
  11.  * Written by Linas Vepstas, March 1995
  12.  */
  13.  
  14. /* required include files */
  15. #include <GL/glut.h>
  16. #include <GL/tube.h>
  17.  
  18. /*  most recent mouse postion */
  19. extern float lastx;
  20. extern float lasty;
  21.  
  22. void InitStuff (void) {
  23.    lastx = 121.0;
  24.    lasty = 121.0;
  25. }
  26.  
  27. /* draw the helix shape */
  28. void DrawStuff (void) {
  29.  
  30.    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  31.    glColor3f (0.6, 0.8, 0.3);
  32.  
  33.    /* set up some matrices so that the object spins with the mouse */
  34.    glPushMatrix ();
  35.    glTranslatef (0.0, 0.0, -80.0);
  36.    glRotatef (lastx, 0.0, 1.0, 0.0);
  37.    glRotatef (lasty, 1.0, 0.0, 0.0);
  38.  
  39.    /* Phew. FINALLY, Draw the helix  -- */
  40.    gleSetJoinStyle (TUBE_NORM_EDGE | TUBE_JN_ANGLE | TUBE_JN_CAP);
  41.    gleHelicoid (1.0, 6.0, 2.0, -3.0, 4.0, 0x0, 0x0, 0.0, 1080.0);
  42.  
  43.    glPopMatrix ();
  44.  
  45.    glutSwapBuffers ();
  46. }
  47.  
  48. /* ------------------------- end of file ----------------- */
  49.